package ar.edu.unq.tpi.labso.rochi.agendaRochi.Wicket.evento;

import org.apache.wicket.extensions.markup.html.form.DateTextField;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.SubmitLink;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.model.CompoundPropertyModel;

import ar.edu.unq.tpi.labso.rochi.agendaRochi.Wicket.HomePage;
import ar.edu.unq.tpi.labso.rochi.agendaRochi.Wicket.apliccion.EventoDatProvider;
import clasesPrincipales.Evento;

public class EditarEventoPage extends WebPage {
	private static final long serialVersionUID = 1L;

	final EventoDatProvider provider ;
	public EditarEventoPage( EventoDatProvider provider) {
		
		super(new CompoundPropertyModel<Evento>(
				provider.getSeleccionado()));
		this.provider= provider;
		Form<Evento> form = new Form<Evento>("eventoEditarForm");		
		this.add(form);

		
		form.add(new Label("lbl_finicio","Fecha inicial"));
	    form.add(new DateTextField ("fechaInicio"));
	    form.add(new Label("lbl_ffin","Fecha final"));
	    form.add(new DateTextField ("fechaFin"));
	    form.add(new Label("lbl_descr","Descripcion"));
	    form.add(new TextField<String>("descripcion"));
	    form.add(new Label("lbl_importante","Es importante"));
	    form.add(new CheckBox("esImportante"));
		
		  form.add(new SubmitLink("botonEditarEvento"){
			private static final long serialVersionUID = 1L;
			public void onSubmit() {
				EditarEventoPage.this.provider.editar((Evento)EditarEventoPage.this.getDefaultModelObject());
				this.setResponsePage(new HomePage());
			}});
		  form.add(new Link("botonVolverHome"){
				private static final long serialVersionUID = 1L;
				public void onClick() {
					EditarEventoPage.this.setResponsePage(new HomePage());
				}});
				
		};
	}
